Repository navigation
ci(release): push release tags and changelog as the CI bot GitHub App - #391
Merged
Merged
Conversation
reusable-release: build-go checks out with the app token it mints (checkout persisted GITHUB_TOKEN, whose extraheader overrode the app token in gha-release-go's push URL) and collect-changelog tries the app token first for the direct push to the default branch. New optional input ci-bot-app-client-id and secret CI_BOT_APP_PRIVATE_KEY select the CI bot app; the legacy CI_APP_* pair still works. Both jobs run in the ci-bot environment and their mints are narrowed with permission-* inputs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011To9HQJLrCH6wYa5WCpw3L
…plit collect Revert build-go to its original definition: no bot mint, default checkout. A queue-bypassing token must not be persisted into a checkout where dependency installs, tests and GoReleaser run, and an app-pushed tag would start push:tags workflows in consumers. collect-changelog now takes the environment from a bot-environment input (default none) so only a repository that owns the app key can use it, treats a client id without a key as mode none with a warning outside an environment, and is split so the step that installs scriv (pinned to 1.8.0) and collects holds no token; the app token, PAT and GITHUB_TOKEN reach only the publish step, which re-verifies the commit before pushing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011To9HQJLrCH6wYa5WCpw3L
Separate steps of one job share $GITHUB_ENV, $GITHUB_PATH, git hooks and config, so a malicious scriv dependency could reach the publish step's token. collect-changelog becomes collect-changelog-build (no environment, no secrets, contents: read; installs scriv==1.8.0, collects, uploads a patch) and collect-changelog-publish (bot-environment, installs nothing; fresh checkout, verifies the patch touches only CHANGELOG.md and changelog.d/ as plain regular files, applies it with hooks disabled, commits as the app, pushes or opens the PR). build-status needs both. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011To9HQJLrCH6wYa5WCpw3L
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes (
reusable-release.yml2.17.0 to 2.19.0)Scope is
collect-changelogonly.build-gois unchanged (defaultGITHUB_TOKENcheckout, no bot mint): a queue-bypassing token must not be persisted into a checkout where dependency installs, tests and GoReleaser run, and an app-pushed tag would startpush: tagsworkflows in consumers.collect-changelognow pushes with the app token, then the PAT, thenGITHUB_TOKEN. Before, the app was only used for the fallback PR, so a ruleset bypass naming the app never helped and every collect fell through to the PR. The commit is authored as the app's bot account (user id looked up at runtime; a failed lookup only warns).ci-bot-app-client-id(falls back to the caller'sCI_BOT_APP_CLIENT_IDvariable) and optional secretCI_BOT_APP_PRIVATE_KEYselect the bot app. The legacyCI_APP_ID/CI_APP_PRIVATE_KEYpair keeps working; with neither the job behaves as before. The legacy secrets andJF_CI_GH_PATare now declared as optionalworkflow_callsecrets (needed once any secret is declared;secrets: inheritcallers are unaffected).bot-environment(default empty); the job declaresenvironment: ${{ inputs.bot-environment }}. Only a caller that holds the key as that environment's secret passes it. Outside an environment, a client id with no visible key ismode=nonewith a::warning::; inside one it is an error. A key without a client id is always an error.$GITHUB_ENV,$GITHUB_PATH, git hooks and config, so a malicious dependency could reach a later step's token; the isolation has to be a job boundary.collect-changelogis replaced by two jobs (build-statusnow needs both):collect-changelog-build: no environment, no secrets,permissions: contents: read. Checks out, installsscriv==1.8.0(exact pin; its 13 transitive dependencies are not hash-pinned, which would be about 375 inline hash lines, and this job holds nothing to steal), collects, and uploads a patch limited by pathspec toCHANGELOG.mdandchangelog.d/. Outputpublishsays whether there is anything to publish.collect-changelog-publish: declaresenvironment: ${{ inputs.bot-environment }}, installs nothing, freshpersist-credentials: falsecheckout. It downloads the patch, applies it to the index with hooks disabled, and judges the result with git's raw diff: only added, modified or deleted regular files (mode 100644) atCHANGELOG.mdor underchangelog.d/; renames, mode changes, symlinks and submodules are rejected. Then the app mint, the open-changelog-PR guard, the commit as the app, and the push or PR as before. I exercised the verifier locally against a good patch (accepted) and rename-out, rename-in, mode change, outside path and symlink patches (all rejected).Prerequisites and consumers
Consumers do not get the bypass key. Only audiobook-organizer holds it, as an environment secret of its own
ci-botenvironment, and it will passbot-environment: ci-botwhen it re-pins (a later audiobook-organizer change, not this PR). Every other consumer passes nothing and ismode=noneormode=legacy, exactly as today. Nothing needs configuring for them.Unverified assumption to check first
I could not confirm from the GitHub docs that
environment:evaluating to an empty string means "no environment" (the docs only say the name can be an expression). The patternenvironment: ${{ cond && 'name' || '' }}is widely used and is expected to run without an environment, but the first run of this workflow in a consumer that passes nobot-environmentmust be checked before others re-pin. If it errors, switch to an expression that yieldsnull, or split the job.Verification checklist
actionlint .github/workflows/reusable-release.ymlclean (run).bot-environment(legacy secrets or none): the release runs, the job shows no environment,mode=legacyormode=none, behaviour unchanged.bot-environment: ci-bot: log showsmode=bot, "CHANGELOG.md updated for " (not "refuses direct pushes"), the changelog commit authored by the app bot (gh api "repos/<owner>/<repo>/activity?ref=<default>&per_page=1" --jq '.[0].actor.login'is<app-slug>[bot]), and nochangelog/collect-*PR.environmentand no secrets in its log; the publish job log shows nopipornpmstep.Companion PR: falkcorp/audiobook-organizer (the four in-repo bot workflows).
🤖 Generated with Claude Code
https://claude.ai/code/session_011To9HQJLrCH6wYa5WCpw3L